﻿


using Micro.Core.Packages;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;

namespace Microsoft.Extensions.DependencyInjection
{
    public class GrpcPack : BasePackage
    {

        public override PackLevel Level => PackLevel.Application;

        public override int Order => 1;

        public override IServiceCollection AddServices(IServiceCollection services)
        {

            services.AddGrpc(options => options.EnableDetailedErrors = true);
            //services.AddGrpcHttpApi();
            // enable ServiceModel.Grpc
            services.AddServiceModelGrpc();

            // enable ServiceModel.Grpc integration for Swashbuckle.AspNetCore
            services.AddServiceModelGrpcSwagger();
            return base.AddServices(services);
        }


        public override void UsePack(WebApplication app)
        {
            app.UseServiceModelGrpcSwaggerGateway();
            //Grpc服务
            //app.MapGrpcService<>();
            base.UsePack(app);
        }

        public override void UseHostBuilder(IHostBuilder hostBuilder, IServiceProvider services)
        {
            base.UseHostBuilder(hostBuilder, services);
        }

    }
}